/************************************* * File: array.cpp * Author: Katherine Gibson * Date: 2/11/2016 * Section: N/A * E-mail: k38@umbc.edu * Description: * This program creates an array * and displays the locations in * memory of its various "parts" *************************************/ #include using namespace std; const int ARRAY_SIZE = 5; int main() { int i, myArray[ARRAY_SIZE] = {20,30,40,50,60}; // display the value of each array element for (i = 0; i < ARRAY_SIZE ; i++) { cout << "myArray at " << i << " is " << myArray[i] << endl; } cout << endl; // display the value of each array element's location in memory for (i = 0; i < ARRAY_SIZE ; i++) { cout << "myArray at index " << i << " is located at " << &(myArray[i]) << endl; } cout << endl; // display the value and address of the "myArray" variable cout << "The value of the variable myArray is " << *(myArray) << endl; cout << "The address of the variable myArray is " << &(myArray) << endl; return 0; }